//
//  SearchAllTitleView.m
//  NewMusic
//
//  Created by dllo on 15/11/23.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "SearchAllTitleView.h"

@implementation SearchAllTitleView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatSubView];
    }
    return self;
}
- (void)creatSubView
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 40, 40);
    [button setTitle:@"单曲" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor colorWithRed:150 / 255.0 green:150 / 255.0 blue:150 / 255.0 alpha:1.0] forState:UIControlStateNormal];
    [button setTitleColor:[UIColor colorWithRed:56 / 255.0 green:192 / 255.0 blue:107 / 255.0 alpha:1.0] forState:UIControlStateSelected];
    button.tag = 11004;
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    button.selected = YES;
    
    UIButton *buttonMV = [UIButton buttonWithType:UIButtonTypeCustom];
    buttonMV.frame = CGRectMake(40, 0, 40, 40);
    [buttonMV setTitle:@"MV" forState:UIControlStateNormal];
    [buttonMV setTitleColor:[UIColor colorWithRed:150 / 255.0 green:150 / 255.0 blue:150 / 255.0 alpha:1.0] forState:UIControlStateNormal];
    [buttonMV setTitleColor:[UIColor colorWithRed:56 / 255.0 green:192 / 255.0 blue:107 / 255.0 alpha:1.0] forState:UIControlStateSelected];
    buttonMV.tag = 11005;
    [buttonMV addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:buttonMV];
}
- (void)buttonAction:(UIButton *)sender
{
    UIButton *button = (UIButton *)[self viewWithTag:11004];
    UIButton *buttonMV = (UIButton *)[self viewWithTag:11005];
    if (sender == button)
    {
        if (!button.selected)
        {
            button.selected = !button.selected;
            buttonMV.selected = !buttonMV.selected;
        }
        [self.delegate buttonChangeCellWithNum:0];
    } else {
        if (!buttonMV.selected)
        {
            button.selected = !button.selected;
            buttonMV.selected = !buttonMV.selected;
        }
        [self.delegate buttonChangeCellWithNum:1];
    }
}
@end
